home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Marlais / Marlais 0.5.9-portable sources / foreign.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-15  |  2.3 KB  |  95 lines  |  [TEXT/ttxt]

  1. /*
  2.  
  3.    foreign.c - foreign function interface
  4.  
  5.    This software is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2 of the License, or (at your option) any later version.
  9.  
  10.    This software is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Library General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Library General Public
  16.    License along with this software; if not, write to the Free
  17.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.    Original copyright notice follows:
  20.  
  21.    Copyright, 1993, Brent Benson.  All Rights Reserved.
  22.  
  23.    Permission to use, copy, and modify this software and its
  24.    documentation is hereby granted only under the following terms and
  25.    conditions.  Both the above copyright notice and this permission
  26.    notice must appear in all copies of the software, derivative works
  27.    or modified version, and both notices must appear in supporting
  28.    documentation.  Users of this software agree to the terms and
  29.    conditions set forth in this notice.
  30.  
  31.  */
  32.  
  33. #include "foreign.h"
  34. #include "prim.h"
  35.  
  36. static Object load_foreign (Object name);
  37.  
  38. static struct primitive foreign_prims[] =
  39. {
  40.     {"%load_foreign", prim_1, load_foreign},
  41. };
  42.  
  43. void
  44. init_foreign_prims (void)
  45. {
  46.     int num;
  47.  
  48.     num = sizeof (foreign_prims) / sizeof (struct primitive);
  49.  
  50.     init_prims (num, foreign_prims);
  51. }
  52.  
  53. #ifdef DLOPEN
  54. #include <dlfcn.h>
  55.  
  56. static Object
  57. load_foreign (Object name)
  58. {
  59.     char *filename;
  60.     void *handle;
  61.  
  62.     filename = BYTESTRVAL (name);
  63.     handle = dlopen (filename, RTLD_LAZY);
  64.     if (!handle) {
  65.     error ("load-foreign: could not load file", name, NULL);
  66.     }
  67.     return (make_integer ((int) handle));
  68. }
  69.  
  70. #endif /* DLOPEN */
  71.  
  72. #ifdef powerc
  73. // load a function from a container with code fragment manager.
  74.  
  75. static Object
  76. load_foreign (Object name)
  77. {
  78.     char *filename;
  79.     void *handle;
  80.  
  81.     error ("load-foreign: not implemented yet ", name, NULL);
  82.  
  83. #if 0
  84.     filename = BYTESTRVAL (name);
  85.     handle = dlopen (filename, RTLD_LAZY);
  86.     if (!handle) {
  87.     }
  88.     return (make_integer ((int) handle));
  89. #endif
  90.  
  91.     return unspecified_object;
  92. }
  93.  
  94. #endif
  95.